package entity

import (
	"time"
)

type MainAccountEntity struct {
	Id          uint
	Nickname    string
	Avatar      string
	Password    string
	PhoneNumber string
	Email       string
	Address     AddressValueObject
	CreateTime  time.Time
}

type AddressValueObject struct {
	Province string
	Block    string
	Unit     uint8
}

func (entity *MainAccountEntity) GetAddress() AddressValueObject {
	return entity.Address
}

func (entity *MainAccountEntity) UpdateAddress(province, block string, unit uint8) {
	entity.Address = *NewAddress(province, block, unit)
}

func (entity *MainAccountEntity) ChangePassword(psw string) {
	entity.Password = psw
}

func NewAddress(province, block string, unit uint8) *AddressValueObject {
	return &AddressValueObject{
		Province: province,
		Block:    block,
		Unit:     unit,
	}
}
